
Imports Microsoft.VisualBasic
Imports System.Data
Namespace cBussines
    Public Class Customer
        Dim _name As String
        Dim _id As Long
        Dim _address As String
        Dim _phone As String
        Dim _rfc As String
        Public Sub New(ByVal sName As String, ByVal sAddress As String, ByVal sPhone As String)
            Me.Address = sAddress
            Me.Name = sName
            Me.Phone = sPhone
        End Sub
        Public Sub New()
            MyBase.New()
        End Sub
        Public Property id() As Long
            Get
                Return _id
            End Get
            Set(ByVal value As Long)
                _id = value
            End Set
        End Property
        Public Property Name() As String
            Get
                Return _name
            End Get
            Set(ByVal value As String)
                _name = value
            End Set
        End Property
        Public Property Address() As String
            Get
                Return _address
            End Get
            Set(ByVal value As String)
                _address = value
            End Set
        End Property
        Public Property Phone() As String
            Get
                Return _phone
            End Get
            Set(ByVal value As String)
                _phone = value
            End Set
        End Property
        Public Property RFC() As String
            Get
                Return _rfc
            End Get
            Set(ByVal value As String)
                _rfc = value
            End Set
        End Property
    End Class

    Public Class Product
        Dim _amount As Integer
        Dim _price As Double
        Dim _taxes As Double
        Dim _name As String
        Dim _id As Long        
        Public Property id() As Long
            Get
                Return _id
            End Get
            Set(ByVal value As Long)
                _id = value
            End Set
        End Property
        Public Property Name() As String
            Get
                Return _name
            End Get
            Set(ByVal value As String)
                _name = value
            End Set
        End Property
        Public Property Amount() As Integer
            Get
                Return _amount
            End Get
            Set(ByVal value As Integer)
                _amount = value
            End Set
        End Property
        Public Property Price() As Double
            Get
                Return _price
            End Get
            Set(ByVal value As Double)
                _price = value
            End Set
        End Property
        Public Property Taxes() As Double
            Get
                Return _taxes
            End Get
            Set(ByVal value As Double)
                _taxes = value
            End Set
        End Property
        Public Function FindByName(ByVal sName As String) As DataSet
            Dim a As New DataSet
            Return a
        End Function
        Public Function FindByCategory(ByVal sCategory As String) As DataSet
            Dim a As New DataSet
            Return a
        End Function
    End Class

    Public Class Products
        Dim _Products As New ArrayList
        Public Sub Add(ByVal pProd As Product)
            _Products.Add(pProd)
        End Sub
        Public Function Item(ByVal Index As Long) As Product
            Return _Products(Index)
        End Function
        Public Function Count() As Long
            Return _Products.Count
        End Function
        Public Sub Remove(ByVal Item As Product)
            _Products.Remove(Item)
        End Sub
    End Class


    Public Class Buy
        Dim _mainClient As Customer
        Dim _products As New Products
        Public Sub New(ByVal pProducts As Products, ByVal cCustomer As Customer)
            _products = pProducts
            _mainClient = cCustomer
        End Sub
        Public Sub New()
            MyBase.New()
        End Sub
        Public Function Process() As String
            Return "Success"
        End Function
        Public Function findByProduct() As DataSet
            Dim Ds As New DataSet
            Return Ds
        End Function
        Public Function findByBuy() As DataSet
            Dim Ds As New DataSet
            Return Ds
        End Function
        Public Sub assignClient(ByVal _client As Customer)
            _mainClient = _client
        End Sub
        Public Sub addProduct(ByVal Prod As Product)
            _products.Add(Prod)
        End Sub
        Public Sub modifyProduct(ByVal lastProduct As Product, ByVal newProduct As Product)
            _products.Remove(lastProduct)
            _products.Add(newProduct)
        End Sub
        Public Sub CancelProduct(ByVal ProductToCancel As Product)
            _products.Remove(ProductToCancel)
        End Sub
        Public Sub CancelProduct(ByVal idProduct As Long)
            Dim _i As Long
            For _i = 0 To _products.Count
                If _products.Item(_i).id = idProduct Then
                    Dim prod As Product = _products.Item(_i)
                    _products.Remove(prod)
                End If
            Next

        End Sub
    End Class
End Namespace

